#ifndef MAGICDOCVIEW_H_HEADER_INCLUDED_B4F2C129
#define MAGICDOCVIEW_H_HEADER_INCLUDED_B4F2C129

#include <wx/app.h>
#include <wx/docview.h>
#include <wx/textctrl.h>
#include "../MagicDocApp.h"

class MagicDocFrame;

class TextEditView : public wxView
{
protected:
    wxTreeItemId    m_folderId;
    MagicDocFrame*  m_mainFrame;
public:
    TextEditView(): 
        wxView(), m_childPanel(NULL), m_text(NULL), m_doc(NULL), m_firstTime(true)  ,
        m_mainFrame(NULL)
    {};
    ~TextEditView();

    void SetFrame(MagicDocFrame* mainFrame);

    virtual bool OnCreate(wxDocument *doc, long flags);
    virtual void OnDraw(wxDC *dc);
    virtual bool OnClose(bool deleteWindow = true);

    wxTextCtrl *GetText() const { return m_text; }
    void SetFolderId(wxTreeItemId folderId){ m_folderId = folderId; }
    
    wxTreeItemId GetFolderId(){ return m_folderId; };
    const MagicDocChildFrame* GetChildFrame(){ return m_childPanel; };

protected:
    bool m_firstTime;
    wxDocument *m_doc;
    int m_idTextCtrl;
    void OnTextChanged(wxCommandEvent& event);
private:
    void OnCopy(wxCommandEvent& WXUNUSED(event)) { m_text->Copy(); }
    void OnPaste(wxCommandEvent& WXUNUSED(event)) { m_text->Paste(); }
    void OnSelectAll(wxCommandEvent& WXUNUSED(event)) { m_text->SelectAll(); }

    MagicDocChildFrame *m_childPanel;
    wxTextCtrl *m_text;

    DECLARE_EVENT_TABLE()
    DECLARE_DYNAMIC_CLASS(TextEditView)
};


#endif 
